'use client' import { useEffect, useState } from 'react' import { useParams } from 'next/navigation' import Link from 'next/link' import { ArrowLeft, Loader2 } from 'lucide-react' import { ReportView } from '@/components/report-view' import type { ReportContent } from '@/lib/report' interface ReportData { id: string title: string generatedAt: string contentJson: ReportContent sessionCount: number } export default function ReportDetailPage() { const params = useParams() const id = params.id as string const [report, setReport] = useState(null) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { async function load() { try { const res = await fetch(`/api/reports/${id}`) if (!res.ok) throw new Error('Report not found') setReport(await res.json()) } catch (e) { setError((e as Error).message) } finally { setLoading(false) } } load() }, [id]) if (loading) { return (
Loading report...
) } if (error || !report) { return (
Back to reports
{error || 'Report not found'}
) } return (
Back to reports Generated {new Date(report.generatedAt).toLocaleString()} ยท {report.sessionCount} sessions
) }